home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / arrayprepend.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.0 KB  |  36 lines

  1. <!--- This example shows ArrayPrepend --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>ArrayPrepend Example</TITLE>
  5. </HEAD>
  6.  
  7. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  8. <BODY  bgcolor="#FFFFD5">
  9.  
  10. <H3>ArrayPrepend Example</H3>
  11.  
  12. <CFQUERY NAME="GetEmployeeNames" DATASOURCE="cfsnippets">
  13. SELECT FirstName, LastName FROM Employees
  14. </CFQUERY>
  15. <!--- create an array --->
  16. <CFSET myArray = ArrayNew(1)>
  17. <!--- set element one to show where we are --->
  18. <CFSET myArray[1] = "Test Value">
  19. <!--- loop through the query and append these names
  20. successively before the last element (this list will
  21. reverse itself from the standard queried output, as
  22. it keeps prepending the array entry) --->
  23. <CFLOOP query="GetEmployeeNames">
  24.     <CFOUTPUT>#ArrayPrepend(myArray, "#FirstName# #LastName#")#</CFOUTPUT>, Array was prepended<BR>
  25. </CFLOOP>
  26. <!--- show the resulting array as a list --->
  27. <CFSET myList=ArrayToList(myArray, ",")>
  28. <!--- output the array as a list --->
  29. <CFOUTPUT>
  30.     <P>The contents of the array are as follows:
  31.     <P>#myList#
  32. </CFOUTPUT>
  33.  
  34. </BODY>
  35. </HTML>       
  36.